Linearization of dynamical systems using integrals of the motion