A Gamma-convergence approach to large deviations