Ensure that the full output path exists before continuing.

Fixes #362.