Chi-square approximation by Stein's method with application to Pearson's statistic