I'm not sure why you can't save the file as .jpg.... since you are using libcurl this shouldnt be a problem:
FILE* f = _tfopen(wLocalFilePath.c_str(), _T("wb+"));
if(!f)
return ERROR_FILE;
curl_easy_setopt(curl, CURLOPT_WRITEDATA, f);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteFileCallcack);
*Note: the code is in C++ and I'm not sure what language you are using but it should give ya a hint if you are using other languages.
wLocalFilePath is the full path of the file where you want to save your downloaded content with the extension of course for example (c:\picture.jpg) and you should open the file to write in binary mode, pass the file pointer to the curl handle along with your write callback function and you should be set.