fixed TIF creation function