Stochastic blockmodels with growing number of classes