We analyze a mesoscopic model of a shear stress material with a three-dimensional slab geometry, under an external quasistatic deformation of a simple shear type. Relaxation is introduced in the model as a mechanism by which an unperturbed system achieves progressively mechanically more stable configurations. Although in all cases deformation occurs via localized plastic events (avalanches), we find qualitatively different behavior depending on the degree of relaxation in the model. For no or low relaxation, yielding is homogeneous in the sample, and even the largest avalanches become negligible in size compared with the system size (measured as the thickness of the slab L_{z}) when this is increased. On the contrary, for high relaxation, the deformation localizes in an almost two-dimensional region where all avalanches occur. Scaling analysis of the numerical results indicates that in this case, the linear size of the largest avalanches is comparable with L_{z}, even when this becomes very large. We correlate the two scenarios with a qualitative difference in the flow curve of the system in the two cases, which is monotonous in the first case and velocity weakening in the second case.