Added creating (missing) folders when saving a file (fixes #171).