Hundreds of flights grounded as typhoon nears Japan