buffer: fix writeInt{B,L}E for some negative values
The algorithm used to convert negative values to hex generates incorrect values when the low byte(s) of the value are zero because a carried subtraction is applied prematurely.
Fixes #3992 (closed)
Signed-off-by: Peter A. Bigot pab@pabigot.com