Ergodicity of observation-driven time series models and consistency of the maximum likelihood estimator