added some directory creation to make sure files can be written