encode for utf-8 output

This makes non-ASCII characters in the input files render properly upon output.