In my experience, the carrier that subsidized your device will charge you a fee to unlock the device from being specific to their network. Usually a phonecall to customer support is all it takes.
You should be able to go to the same type of network by just changing the SIM card. I'd talk with T-Mobile, give them the phone make/model and see if it is compatible with them.