fn to change buffer encoding