email: Fix _flatten() implementation for non-ASCII bodies
The email header should be flattened to ASCII with funky encoded
headers [1], but the body may be encoded in a non-ASCII-compatible
charset (e.g. UTF-16-LE). The old _flatten() implementation used the
body charset to encode the entire message, which could garble the
header. This patch uses BytesGenerator, which takes advantage of
email.charset.Charset's separate fields for the header encoding and
body encoding.
[1]: http://docs.python.org/3/library/email.header.html
Signed-off-by: W. Trevor King <wking@tremily.us>