> print """Content-Type: image/gif > Content-Length: %d > """%(len(buf)) > print buf At the very least you are corrupting the GIF by an extra EOL character. Try: sys.stdout.write(buf) Cheers, Brian