Large deviations upper bound for the Teichmueller flow and applications