jmap_util: change decode_to_utf8 API to prevent off-by-one read error
The previous code could read one byte beyond the length of the
data. This patch also changes the function signature to always
write the result in a byte buffer. While in theory this could
incur unnessary heap allocation, in practice all existing uses
of decode_to_utf8 heap-allocated the result anyway.