This is a problem that only "walled garden" languages like Java and JavaScript would ever even have in the first place. If you're not trapped in a gilded cage, you just print raw bytes directly to a socket and then read data back the same way. The only concern is byte ordering, which is easy.
Regarding this specific approach, "only 20% overhead" sounds pretty good, but base 64 encoding has "only 33% overhead", is completely general, and likely already has faster implementations than this.