Mayor Michael R. Bloomberg and the city’s teachers union have agreed to do away with “rubber rooms” and speed up hearings for teachers accused of wrongdoing or incompetence, ending a disciplinary system that has made both City Hall and the teachers’ union subjects of ridicule.