The MAGIC telescopes are two Imaging Atmospheric Cherenkov Telescopes (IACTs) located on the Canary island of La Palma. The telescopes are designed to measure Cherenkov light from air showers initiated by gamma rays in the energy regime from around 50 GeV to more than 50 TeV. The two telescopes were built in 2004 and 2009, respectively, with different cameras, triggers and readout systems. In the years 2011-2012 the MAGIC collaboration undertook a major upgrade to make the stereoscopic system uniform, improving its overall performance and easing its maintenance. In particular, the camera, the receivers and the trigger of the first telescope were replaced and the readout of the two telescopes was upgraded. This paper (Part I) describes the details of the upgrade as well as the basic performance parameters of MAGIC such as raw data treatment, linearity in the electronic chain and sources of noise. In Part II, we describe the physics performance of the upgraded system.