Fix buffer encoding issues

Change-Id: I7ea36682a77d31988b547acfed90c5c74d62fb3a