Superconducting properties of MgB2 from first principles