Use mmap/munmap instead of malloc/free

This should make it more likely that repeated on/off of the scanning will
work properly. Also change outputBuf to be stack allocated instead of on
the (malloc) heap.