create missing directories for file to write to.