encoding fixes

try extract charset from Content-Type header and encode content with that charset
set content encoding headers once in to_message function