Advice
Take a closer look at the lone pairs and double bonds that participate only and only in the delocalization of electrons.
1-methoxy-1,3,5,7-octatetraene
As you can see, 1-methoxy-1,3,5,7-octatetraene has four double bonds in an octagonal cycle. The lone pairs of the adjacent oxygen atoms, even though they directly influence the delocalization by means of the resonance effect, aren't actually part of the cycle and cannot be included amongst the pi electrons of the double bonds. Therefore, your molecule is antiaromatic. Its structure is not planar, in fact it looks something like this (the picture below includes only the cyclic backbone):

For aromatic molecules, planarity is absolutely necessary. But Huckel's rule which I'm sure you're familiar with, provides the reasoning behind the planarity of the molecule.
The imidazole
As for the imidazole, your assumption is absolutely correct. Here we get to know a scenario similar to pyridine:

The lone pair does not participate in the aromatic cycle. This can be easily checked by taking a look at the hybridization of the nitrogen atom. If the lone pair were to be part of the aromatic system, it should have been perpendicular to the other orbitals of the cycle. However, this is not the case. The 2p orbitals of the nitrogen are actually involved in the aromatic cycle, while the aforementioned paired electrons get to be embedded in an sp2 orbital, placed perpendicular to the plane of the cycle. This actually has significant consequences on the basicity of pyridine.
On the other hand, in order not to interrupt the aromatic cycle, the lone pairs of the other nitrogen atos must come into play when counting pi electrons. Thus, the molecule is aromatic.