Refine exporting image and data to file (append appropriate extension to
file name, and warn users when they accidentally try to write over an
existing file).