Make sure output directory exists before writing output

In case the output is in a subdirectory of `dest`.