Distribution of the magnetic field and current density in superconducting films of finite thickness