fix encode long, read end of buffer