1. Heat the oven to 375 degrees .
2. In a large skillet, saute the onion and mushrooms in the oil over medium-high heat until softened, about 5 minutes. Add the salt and pepper.
3. Squeeze the spinach to remove as much liquid as possible. In a large bowl, stir together the spinach, the cooked onions and mushrooms, the cottage cheese, grated cheeses, and pimientos. Mix in the eggs and flour.
4. Pour the mixture into a lightly greased 2 1/2-quart casserole and bake for 45 minutes.