Law of conservation of mass states that total mass of reactant = total mass of product.
According to law of conservation of energy, energy can neither be created nor be destroyed. So the energy changes are calculated using E=mc2, which will give same results on both the sides. So the masses are calculated in terms of energy.