+3  A: 

Use msvcrt.setmode(1, os.O_BINARY) (after you write the headers and sys.stdout.flush them) to set standard output to binary mode -- poor Apache is innocent, it's a Windows thing;-).

Alex Martelli
Thanks. I added the flush and the setmode, but it didn't help.
Steve Wanamaker
FIXED!!! Thanks!!!msvcrt.setmode(1, os.O_BINARY) is what is needed.The handle for stdout is 1.
Steve Wanamaker