fix outputing image to the browser before the content type header is sent