Just pull SIM Tray out from the outside of iPhone, no need to open iPhone. Take very thin pin, use tweezers to bend the very tip into very small hook, that will still fit into SIM Tray hole. Insert hook only 2 mm into hole, get it to carefully catch, pull the SIM Tray out.
If you ever decide to open an iPhone 3GS, make sure it is OFF.
Another way you could take it out would be to take the screws out that are on the bottom next to were you charge it. Next pop the screen out and if you look on the top inside the phone u will see the sim card. Slide it out with your thumb. Make sure to put the screen back on properly