fix fd_* bitmask calculation
make output filename a command line option, remove debug output