// 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.
// Close the original SeekableOutputStream.