Protect encode_bytes better

Don't write length field too early