Fix surrogate-related UnicodeEncodeError on CSV export

Fixes #210.