Switch IMAP backend to Twisted

We're using Python's imaplib together with our own worker based thread
runner. Twisted implements IMAP functionality similar to imaplib, but
is event-driven which allows us to remove most of our thread code.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>