Improved heat capacity estimator for path integral simulations