Convert a stream of binary digits to a stream of base n digits