Bug 737733 - [IMAPx] Prevent "Stream has outstanding operation" error

...by guarding writes to output streams with a lock, to not write
to the same stream in multiple threads at once.