Handle multibyte characters in environment variables

Send byte size of JSON instead of string length as IO#read uses byte
lengths. If environment contains multibyte UTF-8 characters, byte size
is more than string length and read content is cropped.