tiny winy method to write files

avoid peppering mkdir_p everywhere