ensure content is utf-8 encoded before conversion