Add some IOError checking and create non-existent directories when saving if needed.