An almost sure invariance principle for additive functionals of Markov chains