streambuf implementation