A nonlinear homogenization procedure for periodic masonry