write hook creates a directory if it doesnt exist

- thanks to @monkeez for this
- closes #438