Read and write TIFF images in R