India was all out for 364, opening door for England to stage a dramatic Test cricket win at Headingley on final day.