What is a more formal way to say "Don't get me wrong"?
"Please don't misunderstand me, but..." should suit your needs.
(This is far more polite than the imperative you must understand.)
"Don't get me wrong" and "don't take this the wrong way" mean different things. The former more closely resembles a precursor to a statement refuting or mildly disagreeing with previous statement. For example:
Don't get me wrong; I enjoy children. However (or "having said that", etc), they do bother me at times.
The latter, however, means "I'm about to say something that you might misunderstand, so don't". For example:
Don't take this the wrong way, but you look very tired today.
A way to get around the clunky feeling of "don't take this the wrong way" would be to replace it with "please don't take offence" or something else more specific to the context of the sentence.
Getting around using "don't get me wrong" is even easier. All one needs to do is omit the phrase, but if some of its meaning is still desired, one could begin with "understand that" or "you must understand that" as in this sentence:
You must understand that I enjoy children. However, they do bother me at times.
The phrase "Let me be clear" seems appropriate. However, it is a bit more forceful than "Don't get me wrong."
Interestingly, when I googled this, I found a lot of hits criticizing President Barack Obama for overusing this phrase (along with "Make no mistake," which could also serve in this context). Perhaps that's why it came to my mind?