Bugfix: wrong encode output if third byte in input group is negative.
Add support to decode hex strings.