Found it! I was missing the third line of code. You can use this to display a secure image in your page, or download it as jpg Got the first two lines from another question in stackoverflow
//need this two lines to work properly on IE8
header("Pragma: ");
header("Cache-Control: ");
//was missing this line
header('Content-Disposition: attachment; filename="renamed.jpg"');
header("Content-Type: image/jpeg");
echo file_get_contents("images/somepic.jpg");