replace function body with:
	if len(b.buf) < need {
		// expand buffer if neccessary
		b.buf = append(b.buf, make([]byte, need - len(b.buf)))
	}
	if need < b.length {
		// fill buffer with data
		if err = b.fill(need); err != nil {
			return
		}
	}
	p = b.buf[b.idx:b.idx + need]
	b.idx += need
	b.length -= need
	return