Replace invalid characters when encoding header and footers.
Fixes #409 (closed)
Characters in header and footer templates or replacements that can't be represented in the list's preferred character set will throw UnicodeEncodeError if the header/footer is being added as a separate MIME part. This uses errors='replace'
to avoid the exception.
Edited by Mark Sapiro