fix UnicodeEncodeError for non-ascii data