Write to "sys.stdout" with desired encoding

This fixes #148.

This is similar to @e34540c81093c49b972e2249f595dd6eb989bb1a.