view: fix UnicodeEncodeError on write