The word is "ternary", by the way.
A useful intermediate representation would be "binary coded ternary" (BCT?) whereby 121 gets represented as 011001. The code 11 isn't used, just like 1010 through 1111 are not used in binary-coded decimal (BCD).
The 10 bit BCT representation of a five digit ternary number could index into an array of 1024 entries, each yielding its numeric value, that fits into a byte.
Likewise, a reverse table of 243 values can map to a 10 bit BCT.
Conversions between BCT and textual digits are trivial.
The way I have in mind is the same way you'd separate out the digits in a decimal number, except you'd use 3 instead of 10 in the math.
Writing is the harder part. I suppose you could just make 15 such tables, one for each possible value you could write.
The code gets more complex and slow, but not really by much.