use sys.stdout.write instead of print (fix #8)