Instead encode strings and arbitrary buffers using a format similar to the storage of Pascal strings: a size integer, which uses the variable-length scheme above, followed by a string of bytes. This would allow strings/buffers of any length.
Variable length types in Nxt binary format use Pascal approach.