He was getting transferred because the Suits had some blackmail on Pope. Pope had a son that he didn't tell his wife about when she learned of his affair. The son died, and Pope felt guilty for not being there for him. Michael told Pope that Lincoln was his brother and he wanted to be there for him in the end. At the end of the show Pope cancelled the transfer out of guilt over his son's death, he wanted Scofield to have that opportunitu of being there, he stood up to the blackmail and told his wife pre-emptively what the Suits were going to tell her.
As far as being out of cell, Michael went up to the roof and checked on the timing of the response from police, etc to a missing prisoner. He then snuck back into Pope's office where he pretended that he had been working on Pope's Model the entire time. Since Pope, and the 1 guard "knew" he was there, he didn't get into trouble. They didn't know that he had a key and was able to sneak out the backdoor.