Mechanisms of shear band formation in heterogeneous materials under compression: The role of pre-existing mechanical flaws