Numerical integration of differential equations in the presence of first integrals: observer method