The server SHOULD respond to your request with a mime-type/content-type header.
$ch = curl_init("http://url.com/image.jpg?blablabla");
$info = curl_getinfo($ch);
curl_close($ch); // always close handle
Extensions are not really important, from what I understand they only serve two purposes:
1) to help end-users identify types of files without having to open them
2) for operating systems to add some type of image/logo and default program associated with an extension.
They carry absolutely zero weight as far as the file's actual contents go. The only reason your .php files are executed using PHP is because there is an apache directive more or less like this:
AddHandler x-httpd-php5.3 .php
You can rename all of your php files jpg and add this directive:
AddHandler x-httpd-php5.3 .jpg