I tried using sys.stdout.write() but had the same problem. As different browsers give the same corrupted image, it must be my webserver (Xitami on Windows 98). Thanks for the replies.