Your CNN is too small (<1000 parameters, e.g. second layer trains 12*6*3*3+12 scalars). Compare this to 400x784 matrices used in FC network. Additionally, mu and logvar should probably be generated using linear layers.