decode with buffer