Export to path or file (not just path)

Addresses https://bugs.launchpad.net/oq-engine/+bug/1202259

https://github.com/gem/oq-engine/pull/1229 should merge first for a clean diff.