Ensemble epistasis: thermodynamic origins of nonadditivity between mutations