Well I have recently found my old iPhone 3g which I had previously jailbroken and unlocked however u want to know the best and safest way to go around upgrading to ios 4.x or just a new version I know you can harm your phone in the process by just upgrading it.

I'm not concerned if the upgrade wipes all my stuff or even if the jail break goes all I want is for
my phone to be unlocked to any network? And help will gladly apprieciated.