Flux is not coming zero, although charge inside it is zero! 
In the figure, there are two capacitors connected in series. So, they have same charge on them. Since, the plates have same area, therefore they have same charge densities σ.
Also, one capacitor have dielectric slab with dielectric constant 3 and other have 6.
Now, I have drawn a gaussian surface as shown in figure.
Flux entering and exiting in upper capacitor are shown in red, & flux entering and exiting in lower capacitor are shown in blue.
In upper capacitor, Electric field will have magnitude σ/(6ε_0 ) [Due to k=3]
And lower one will have σ/(12ε_0 )  [Due to k=6]
Summing up the flux, it is not coming zero. But it should come zero as no charge is present inside the gaussian surface.
 A: Your diagram could be simpler than it is, since the two plates in the middle are at the same potential and there should be no field lines between them, but that does not affect the essence of your question.
The main issue here is that, due to the polarization of dielectric (as mentioned by Javier in the comments), charge density at and near the plates has to be reviewed.
The diagram below (copied from this site) shows a dielectric slab between the plates of a capacitor with deliberately large gap between them.

The charges on the two sides of the dielectric, $\sigma_{ind}$ and $-\sigma_{ind}$, are due to the polarization of the dielectric and are referred to as induced charges. You can read more about it on the same site.  
Looking at the diagram, we can say that the field in A will be $\frac {\sigma} {\epsilon_0}$, i.e, it will be determined by the charge density on the plates, $\sigma$, and won't be affected by the induced charges on the dielectric.   
On the other hand, the field in B will depend on both plates and dielectric charges. More specifically, the field generated by the charges on the plates will be weakened by the field generated by the induced charges on the dielectric.
If you take this into account, you'll find that the net charge enclosed in the Gaussian surface on your diagram is not zero. This is because, the magnitude of the negative induced charge on the top dielectric surface of the bottom capacitor will be greater than the positive induced charge on the bottom dielectric surface of the top capacitor.
Once again, the site mentioned earlier, could be helpful for your calculations.     
