Pass JSON message lengths as fixed-length numbers

Avoids needing to buffer on the Python end, which can cause trouble
(poll says there's no data waiting, because it's in the buffer, so we
just block forever).