Edit (Nov 2015): I feel it would be disingenuous not to mention that my views on this matter have evolved since posting my original answer, which remains un-edited, below. I suppose the provided answer could be contextualized specifically in the setting of a mathematics course for undergraduate mathematics majors that is primarily lecture-based. If you are a stick-to-the-script sort of lecturer, and are trying to get through material at a fast pace, then the suggestion may still be useful. If your class incorporates student discussion and you are willing to draw from scripts but also improvise in your teaching, then I think the approach of, after getting lost in a mistake, deciding to state a result holds by fiat and moving on - then providing written notes for the next class meeting - may be unnecessarily rigid, and, ultimately, sub-optimal. From a "meta"-perspective, I would consider my earlier answer mistaken, and, personally, I find the remarks of JPBurke here to be much more enlightening.
Since my answer was accepted, I cannot (per StackExchange rules) delete it. Since it was up-voted a fair amount, I think editing over its content significantly would be misleading. Hence this disclaimer.
Anecdote: I know a very experienced and well-liked professor (emeritus, now) of mathematics who would send a small square of chocolate via snail mail to any student who pointed out a mistake. The professor brought in typed up versions of what he was going to cover each class meeting, and the mistake could be anything said aloud, written on the board, or typed up in his notes. (Related: Donald Knuth's policy.)
How should one best handle the situation in the following cases:
$1.$ you realize it yourself more or less immediately
Either correct it immediately or pause and tell the class that you made a mistake. Ask everyone to spend a minute looking for it. (Of course, this will only make sense in certain scenarios; for example, it probably would not make sense in writing down the givens before proving a theorem, since students don't know what result you are aiming for.)
$2.$ you realize it only much later because something (e.g. a proof) is not working properly
If it's straightforward to go through and correct it (e.g., a minus sign is missing in several places) then either follow the advice of $1$ above or draw a hard line on the board, remark what the error is, and write what's correct. If you aren't even sure what the correct conclusion should be by then, then admit the mistake, note that everyone makes them (it would be nice for students to get 100s on all tests, but unlikely) and abandon ship to focus on the next result.
In any event, type up a clean version of the result and its proof to hand out (and possibly discuss) during the next class period.
$3.$ you don't realize it at all but a student tells you in front of the class (this happened to me)
Thank the student, and ask him or her (if possible) to explain why it is an error to the rest of the class. Ask if another student can suggest a way to fix it. Then decide whether going back over what has been written would be a good use of class time, or whether you should ask that they accept the conclusion on faith for the time being. (You might even put such a decision to a majority vote.)
Once again, in any case you should type up a clean version of the related mathematics to distribute (and possibly discuss) during the next class period.