David Cameron thanked those who had supported him during his time as prime minister as he left Downing Street for the final time.