Boundary scattering and weak localization of electrons in a magnetic field