A model for the formation and evolution of traffic jams