Encoding of integers using variable-length encoding