// Seek backward to the IFD offset and write IFD.
sos.seek(ifdOffset);
writeDirectory(ifdOffset, fields, nextIFDOffset);
// Seek forward to position after data.
sos.seek(savePos);
} else if(tempFile != null) {
// Using a file cache for the image data.
// Open a FileInputStream from which to copy the data.