Download iOS 4.3.3 for iPhone 3GS (Google it), and the latest version of sn0wbreeze (Google it). Open up sn0wbreeze, navigate to the 4.3.3 ipsw you downloaded earlier, go to : Expert Mode,press on General, then Next ( the blue button in the corner), then tick : Activate the iPhone, and Install SSH, then press Next, now click on : Install iPad Baseband, but be sure you read and understand the warning, and only continue if you want your phone unlocked and are willing to accept the consequences that come with iPad Baseband, then press Next, then Next one more time, then press on : Build IPSW. Afterwards follow the on-screen instructions to get your iPhone into PWND DFU Mode, then open iTunes, now hold the SHIFT key and press on : Restore, then navigate to the custom firmware you just made with sn0wbreeze, it should be named "sn0wbreeze_iPhone 3GS-4.3.3.ipsw", and wait for your iPhone to restore. After it restores, open up Cydia, go to : Manage > Sources > repo666.ultrasn0w, and press on : Ultrasn0w, then install it. Voila, you just jailbroke and unlock your iPhone 3GS.
I recommend you add the following repositories :
cydia.hackulo.us
cydia.xsellize.com
repo.insanelyi.com
by going to : Manage>Sources>Edit>Add, and typing each one of them. Then install Installous from the Hackulous repository, and you can get any package you want (for free) from xsellize and insanelyi, though I personally use those repositories to test out the packages before I actually buy them; the devs worked hard to make those.
Good luck.