Ensure that the full output path exists before continuing.

Fixes #362.

Also, using `string+other_string` is bad practice in Ruby. If it's a series of paths, use `File.join` – this ensures there aren't any duplicate or omitted `/`. If it's just two strings you'd like to put together, interpolation (`"#{string}.json"`) is preferred.