Prevent UnicodeEncodeError: 'ascii' codec can't encode characters in position ...: ordinal not in range(128)
Encode to utf-8 only when needed