You could define a simple Flatten Module like this:
class Flatten(nn.Module):
    def __init__(self):
        super(Flatten, self).__init__()

    def forward(self, x):
        x = x.view(x.size(0), -1)
        return x

model = nn.Sequential(
            nn.Conv2d(3, 1, 3, 1, 1),
            Flatten(),
            nn.Linear(24*24, 1)
        )

x = Variable(torch.randn(10, 3, 24, 24))
model(x)