mode encoding