Fix a crash in the index encoding

Numbers can be left at 0 bytes (a zero) rather than having 8 \x00 bytes.  The
index encode didn't consider this.