fix toBuffer error