IMPALA-1256: hex and unhex do not return results as expected

hex uses stringstream to convert chars to hex, which in turn requires
the char to be converted to int. This results in undesirable sign-extension
for chars > 0x7F. This fixes masks out all but the least-significant byte after
conversion.
Also, setw is required for each character becasue it is not sticky.
hex(unhex('0303')) was previously producing '033'

Change-Id: Ia6f6a35a324f1a1f99921fb126e7999f21af278c
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1813
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins