Trying to write images from db to tmp folder