Create tmp directory before file write