add encoding support to unpack (compatible with jruby)