Fix endian writing and chunk length calculation.
Fix endian writing and chunk length calculation.

tempbottle/mosquitto,tempbottle/mosquitto,tempbottle/mosquitto,tempbottle/mosquitto,tempbottle/mosquitto