Variance reduction for Markov chains with application to MCMC