Fixed message encoding to use chunks.