Yes, for putting inside JSON, you need a text string. PNG encoding makes sense to me now too.
BTW, I noticed that serializer output and Base64 are almost the same, they use same letters, different special characters, and serializer prepends type and length to the string. Base64 (I mean PNG -> Base64 for small size) format is known and supported outside Haxe too, but it's up to you. :-)