Do a full backup thru iTunes. That way all your data will be saved. If it messes the phone up, you can just do a full restore thru iTunes, then put your data back on the phone. There are also manual ways to do it, but that's the easiest way.
My 3GS is still on 3.x.x software, and jailbroken via Spirit. I'm waiting to run OS4 until the Spirit jailbreak is up for that. There are other ways to jailbreak a 3GS running OS4, but I just prefer Spirit. Mainly because I have the newer boot roms.