messages: detect utf-8 and convert it to valid charset, fixes #74