Add -o option to let users select an output directory

This might not build on Windows because the getopt function is only available on *nix systems, so if Windows compatibility is important then I guess you should deny this pull request.