First, the following grammar produces the language $L_0$ containg words where $n(b) \neq n(a)$ $S \rightarrow U \;|\; V $ $U \rightarrow TbT \;|\; TbU$ $V \rightarrow TaT \;|\; TaV$ $T \rightarrow bTaT \;|\; aTbT \;|\; \epsilon $ It follows your idea of making two cases, and $T$ is the one giving words with equality and is the only non-obvious (but classic) one.
We have a map from $L$ to $L_0$ by transforming every $b$ into an $bb$. Let's try to pull this grammar back through this map. In order to do this, we need a grammar for the image of this map :
We introduce new symbols $U_b, V_b, T_b$ where $b U_b$ is intended to decompose into the words that $U$ can decompose into but beginning with an $b$. We do the same and have new symbols $U^b, V^b, T^b$ where $U^b b$ decomposes into the words $U$ can decompose into but ending with an $b$.
We get (you have to be careful when a $T$ appears because it can be empty) : $ S \rightarrow U \;|\; V $ $ U \rightarrow (T^b b)bT \;|\; Tb(bT_b) \;|\; (T^b b)bU \;|\; Tb(bU_b) $ $ U_b \rightarrow (T_b^b b)bT \;|\; T_b b(bT_b) \;|\; T \;|\; (T_b^b b)bU \;|\; T_bb(bU_b) \;|\; U $ $ V \rightarrow TaT \;|\; TaV $ $ T \rightarrow b(bT_b)aT \;|\; a(T^bb)bT \;|\; aTb(bT_b) \;|\; \epsilon$ $ T_b \rightarrow TaT$ $ T^b \rightarrow b(bT_b)aT^b \;|\; a(T^bb)bT^b \;|\; aTb(bT_b^b) \;|\; aT$ $ T_b^b \rightarrow TaT^b$ which describes the words of $L_0$ where every $b$ appears in a pair $bb$.
Now we can pull back and simplify the two symbols having only one rule and get this :
$ S \rightarrow U \;|\; V $ $ U \rightarrow T^b bT \;|\; TbTaT \;|\; T^b bU \;|\; TbU_b $ $ U_b \rightarrow TaT^b bT \;|\; TaTbTaT \;|\; T \;|\; TaT^b bU \;|\; TaTbU_b \;|\; U $ $ V \rightarrow TaT \;|\; TaV $ $ T \rightarrow bTaTaT \;|\; aT^bbT \;|\; aTbTaT \;|\; \epsilon$ $ T^b \rightarrow bTaTaT^b \;|\; aT^bbT^b \;|\; aTbTaT^b \;|\; aT$
Which should work, if I didn't mess up. Note that this method can be generalized to pulling back any grammar through any such map.