A study of the energy spectrum and composition of cosmic rays up to the highest energies