@Override
	public void write(int b) throws IOException {
		// watch for close
		if (index == 3) throw new IOException("stream closed");
		// map the byte
		b = encmap[b & 0xff];
		int c = b & 0x3f;
		if (radixFree) {
			if (c == b) {
				// still radix free
				bufferByte(position++, chars[ c ]);
			} else {
				// no longer radix free
				flushBufferWithTerm();
				radixFree = false;
			}
		}
		if (!radixFree) {
			// make room for radices
			if (index == 0) position++;
			// check if still radix free
			bufferByte(position++, chars[ c ]);
			// append to the radix and increment counter
			radix |= (b & 0xc0) >> ((++index) << 1);
			// store the radix when full and reset counter
			if (index == 3) {
				bufferByte(position - 4, chars[ radix ]);
				index = 0;
				radix = 0;
			}
		}
		// if the buffer's full, empty it
		if (position == bufferSize) {
			flushBuffer();
		}
	}