It's just another part of the "bust him out" route, just with extra steps. If you think it's a possibility, I'd stat up the mage's tower with a general layout, defenses, and list of items and their location. If the players break into the Mage Tower, you're prepped! If they don't, you've got a nice little layout for if the party ever needs to go there later or something.
It would not be unreasonable for Mr Wizard to have some kind of alarm system that would alert him of a break-in, so he could immediately teleport back.The easy way is to railroad them. Rock falls, the wizard teleports back from the trip. But it is not fun.
Well, you're here now so why not plan something out now? At least lightly sketch it out. I mean golems and magic worms and an elaborate weave of traps, go pick some of those things out, assemble them into the Mage Tower and boom, prepared!The hard way is to make something on the fly. I don't have problems with having to roleplay it, I'm good with improvisation. I have problems with mechanical part - I did not prepare any encounters that would seem logical in a mage's tower. If the tower is guarded by an elaborate weave of traps that activate golems and summon magic flying worms - what are the stats of the golems and the worms? Should I stop the session, go to Google or my paper Bestiary and construct an encounter while players are bored of waiting?.. Or should I wing it and have a risk of wiping the players (or making an encounter extremely easy and non-satisfying?).
IMO, most people are just people, they might have a +1 or a +2 bonus somewhere, a Merchant may be smart, so +1 Will saves. A Soldier may be tough so +1 Fort (if they don't have like, 5 levels of Fighter or something).And such anxiety consumes me in all instances of going off rails. If a player wants to cast a Charm on a merchant to make him give a discount - what should I do mechanically, how high is his Will save? If a players wants to Sneak Attack a questgiver, how much Flat-Footed AC does she have?..
How can I handle this mechanical improvisation?
Ultimately my experience is that you prepare a dozen things, and the players will utilize 2 or 3 of them. Those other things are still prepared, and make it easier to prep more going forward. The best things to prepare are the big things. The Jail. The Mage Tower. The Dungeon. The details of what's in them? Less important. You can fill them up with an assortment of appropriate things once you get there.
A lot of times you just go "Well, this is a pretty average Joe Town Guard, so, 3rd level fighter with good Strength." And yeah, kinda wing it. He'll have a whopping ~30hp, 15AC(Leather +2, shield+2, +1 dex(12)), +3BAB and +3(16 str) to damage and some really pathetic will saves. Boom you have a generic town guard. Copy pasta as many times as you need for more guards.
Plan the Big Stuff. Wing the Small Stuff.