Added file saving functionality to viewer