Prep to improvise.

Have a number of critters available that you're ready to run with. Not necessarily "encounters", but pieces of encounters. Put them together, and be ready to let the PCs flee if there's too much opposition (you *will* make mistakes).

Ideally have some stock floorplans you can use. Yes, it will eventually become obvious they're stock. No, nobody will care.

Once you start improvising, you really open yourself up to how things go... specifically, it becomes feasible for the players to *lose*, especially if you allow them to escape. So how I start planning a scene is something like this:

1) What do the players want?
2) Is it reasonable? (Hint: Presume that if the players think it's reasonable, it's probably reasonable)
3) What can they reasonably get if they're successful?
4) Who wants to stop them, or why is it difficult? If the answer is "nobody, and for no reason" then just give them what they want and go to the actually interesting bits.
5) What happens if they lose? Death is usually not the best option.

A ton of this is implicit in "what the players decide to do". That will suggest the opposition.

As far as "what happens if they lose", I highly suggest this article: https://io9.gizmodo.com/why-you-shou...tent-511712234

Other resources to have ready can include some kind of NPC personality generator (I personally like Short Order Heroes http://calicogames.com/index.html) to help give some personality. Random physical descriptions can help. A list of names is critical.

The ultimate helper though is just any die you have lying around. Any time you're not sure of something, roll a die and take the result. That can provide an inspiration to roll with. "How straight is this guy playing here?". Roll a die. High? He's totally up front. Low, he's deceiving in some way and you can run with that. The goal of these kind of randomizers is not to tell you what is happening, but to help spark you in an interesting direction where you can take over.

And remember that most of the time you don't need to know everything about a situation up front. That can be filled in over time. You need enough to make the scene work.

Make notes about important things and new NPCs, especially ones that the PCs gravitate to or seem to find interesting! You can use these notes to ensure consistency later on and build off of what happens during play.