Eight people have been taken to hospital after the roof of a double-decker bus was ripped off in a railway bridge crash in East Ayrshire.