Update MetadataManager.py

When looking for repository, restore cwd *before* returning from method.
This bug currently results in the output path being relative to the directory of the input file, rather than the cwd of the invocation.
Update MetadataManager.py

Also, restore cwd when exceptions are thrown.
Merge pull request #311 from plinss/output_dir_fix

Update MetadataManager.py