Our main result is an abstract good-λ inequality that allows us to consider three self-improving properties related to oscillation estimates in a very general context. The novelty of our approach is that there is one principle behind these self-improving phenomena. First, we obtain higher integrability properties for functions belonging to the so-called John-Nirenberg spaces. Second, and as a consequence of the previous fact, we present very easy proofs of some of the self-improving properties of the generalized Poincaré inequalities studied by B. Franchi, C. Pérez and R.L. Wheeden in , and by P. MacManus and C. Pérez in . Finally, we show that a weak Gurov-Reshetnyak condition implies higher integrability with asymptotically sharp estimates. We discuss these questions both in Euclidean spaces with dyadic cubes and in spaces of homogeneous type with metric balls. We develop new techniques that apply to more general oscillations than the standard mean oscillation and to overlapping balls instead of dyadic cubes.