Qt 5 compatibility

This one adds Qt 5 compatibility and attempts to resolve several charset-related issues (for example, mime text part can contain multibyte characters which will be killed by toLatin1()).