buffer: strip high bits when converting to ascii

Fixes #4371.

Reviewers: @indutny @piscisaureus