Expulsion of a magnetic field from a superconductor during its transition to the superconducting state