You can drop in a wpa_supplicant.conf file in the boot directory before installing the SD Card into the Pi. When the Pi boots up, the file /etc/wpa_supplicant/wpa_supplicant.conf will be overwritten (or maybe appended, I'm not sure) with the wpa_supplicant.conf file in the /boot/ directory.
Use the following syntax:
The above setup works for standard WPA wifi connections. There are additional settings in the example below:
Make sure to create the wpa_supplicant.conf file in a text editor set to UNIX encoding (if you're doing this from Windows).