I have an apache server that I am using for cgi.  I am writing my cgis in Python.
As long as my responses are of the form "Content-Type: text/html\n #" it works.
But if I send anything else, I get a 500 error and my logs say "malformed header from script. Bad header"  Can I change my configurations to make it work?  Is there anything else I can do?
You need to send a Content-Type header to tell the browser what type of data you're sending it. Without that you'll get the 500 error you're experiencing.
Getting Apache cgi to send json in Python