Hi Jari
From the BLOB help
If you need to save images to a BLOB, and later restore them to an output file, the type of image should also be saved in the database (JPG, GIF, BMP, etc.).
Using BLOBTOFILE to save to a different extension can produce unpredictable results.
Possible problem is that the original file is PNG, and when the Blob is saved to disk it's a base64 encoded png file.
so you probably need to do some decoding and converting the image to different format.
regards
Johan