Quote command line arguments and improve output directory handling. Fixes #130