Add getopt include to main
It is not pulled in by stdlib.h on all systems
Fix buffer formatting on 64bit systems