How to teach a class that I've never taken?
It will be a huge timesaver if you can get lecture notes from someone who has taught the class before.  There's a big difference between understanding the material well enough to solve problems and answer questions and understanding it well enough to find the clearest, most succinct way to present it.  If you get someone else's lecture notes, you will only have to attain the first level of mastery, rather than the second; this will save you a lot of time.

Before the class starts, you should sit down with the syllabus (presumably you can get one from someone who's taught it before; typically, the first time I teach a class, I don't change much unless I have a good reason to) and try to understand the structure ("story arc") of the class.  What are the big ideas?  For example, in Calculus I, some of these are: limits, derivatives, integrals, applications.  That gives you a sense of where you're going and helps you to know what may be important.  

Don't feel like you have to know every little detail perfectly.  The stuff that will likely stump you will be the obscure corner cases.  The stuff that most of your students will struggle with will be much more basic, like the limit definition of a derivative, and precalc and algebra.  If a student asks you a question that you can't answer right away, learn to be comfortable saying "that's a great question"; it's a little outside of the scope of this lecture, but I'd be happy to talk with you about it after class.  

Thinking on your feet in front of an audience (especially about unfamiliar material) can be really tough.  Most of the time, you can avoid it.  Usually the student will be happy to talk with you after class.  The reduced pressure of not being in front of the other students will help you to think more clearly.  If you still can't answer the question after a reasonable amount of time, say "This is a good question.  Let me think about it some more and get back to you in class next time."  At that point, feel free to ask your colleagues.  Often one of them will have encountered the question before, and will know the answer off the top of their head.

tl;dnr Get lots of help from colleagues who have taught the class before.  Typically, it won't take much time from them, but it will save you a lot of time (later, when roles are reversed, be willing to do the same for someone else).  You don't have to be perfect.  If you have decent lecture notes, and you really engage with the students and answer their question, you'll be fine.