Ticket 18967: Fix non-standard message/rfc822 base64 encoding issue (django master)

Django master version of #1202.

https://code.djangoproject.com/ticket/18967