Your .view has the wrong dimensions.
Based on your input size, it should be x = x.view(-1, 64*16*16)
or alternatively x = view(x.size(0), -1).
Since you are pooling twice with kernel_size=2 and stride=2, your height and width will be reduced to 64/2/2 = 16.
Therefore, you also have to change the in_features of fc1 to 64*16*16.