These are instructions on how to unlock the iPhone 3GS for use with any GSM cellphone carrier using PurpleSn0w. Geohot has posted stating that the purplesn0w unlock should improve issues with wifi, battery, and the unlock itself. If you would prefer to use the iPhone Dev-Teams UltraSn0w unlock you can find those instructions here
Before you can follow these instructions you must have a jailbroken iPhone and you must be on the 04.26.08 baseband(modem firmware). This means that you must be running the 3.0 firmware and have used PwnageTool, RedSn0w, or PurpleRa1n to jailbreak. YOU MUST ALSO (FOR THE TIME BEING) HAVE ACTIVATED YOUR IPHONE WITH AN OFFICIAL APPLE CARRIER. NO HACTIVATION SUPPORT YET.
To find your firmware and modem firmware(baseband) versions you can follow this tutorial. If you are not on baseband version 04.26.08 then you need to follow one of these tutorials before unlocking: Mac, Windows
If you are on T-Mobile or any carrier without 3G remember to turn it off before starting...
Press to launch Cydia Installer from your SpringBoard.
Press to select the Manage tab at the bottom of the screen.
Press to select the large Sources button
Press the Edit button at the top right of the screen.
Press the Add button at the top left of the screen.
Enter http://apt.geohot.com/ as the source url and press the Add Source button.
Once the source has been added press the large Return to Cydia button.
Press the Done button at the top right of the screen.
Press to select apt.geohot.com from the list of user entered sources.
Press to select com.geohot.purplesn0w from the list of packages
Press the Install button at the top right of the screen.
Press the Confirm button at the top right of the screen.
After installation completes successfully press the large Return to Cydia button.
Now press the Home button then power off and power on the iPhone. You do this by holding down the power button for 3 seconds then moving the power slider that appears to the right. Press the power button again to turn on the phone.
You should now be able to insert the SIM of your choice!