Galaxy evolution in cosmological simulations with outflows ― I. Stellar masses and star formation rates