properly encode bytes in json
fix problems caused by string to bytes transfer