Calculation of intermolecular potentials for H2H2 and H2O2 dimers ab initio and prediction of second virial coefficients