I have solved this issue using this technique:
$temp = tempnam("tmp/", "IMG_");
$handle = fopen($temp, "w+");
fwrite($handle, $row['front_img']);
$image = new image($temp, constants::UPLOADDIR_PRODUCTS);
$thumb = $url.$image->create_image('thumb');
$image = new image($temp, constants::UPLOADDIR_PRODUCTS);
$img = $url.$image->create_image('normal');
$image = new image($temp, constants::UPLOADDIR_PRODUCTS);
$detail = $url.$image->create_image('detail');
if ($products->saveimages($row['id'], $thumb, $img, $detail, 'front'))
{
echo 'front saved for '.$row['id']."<br/>\n";
}
fclose($handle); // this removes the file
unset($thumb, $img, $detail);