Use bytes for sys.stdout.write in PY2.  Closes #161.