Fix bufread implementation. This fixes problems with codecs that use it.