Fix buffer overrun in header bytes

There are 29 header bytes!  This then overwrote the header length
which is why I ended up with the wrong number of header bytes in
the output file!

Also fixed checking the length to make sure we're not getting more
than 29!