Use sys.stdout.write.