encode_variable_int() went into an infinite loop if input was negative.
Now raises ValueError instead.