The IMAP4 protocol optionally uses double quoting when mailboxes contain
spaces. This is always allowed. So to fix this, first we use shlex to
perform double-quote-aware splitting (a bit like bash would split
command line arguments) and then we send folder names with quotes to the
IMAP server.
I tested this manually with a couple real IMAP servers.
The imaplib module in Python 3 returns payloads as bytes, which are not
automatically converted to strs. That's a good thing! But we need to
encode manually.