Duality for nonlinear filtering