encode response