Since you have jailbroken and unlocked your iPhone 3GS, You will loose both jailbreak and unlock after the restoration process. To avoid this hassle every time, You need to unlock your iPhone using any permanent unlocking method. For example, You can visit ClassicUnlocking.Com and get the remote unlocking service. This method of unlocking is safe, simple, affordable, quick and permanent. It doesn't require a jailbreak too. Good luck.