Use the fact that when angles correspond to equally spaced points around a circle, their sines add up to zero and their cosines do the same. Thus
$\cos(\frac{\pi}{4})+\cos(\frac{\pi}{4}+\frac{2\pi}{3})+\cos(\frac{\pi}{4}+\frac{4\pi}{3})=0$
Put $\cos(\frac{\pi}{4})=\frac{\sqrt{2}}{2}$, then:
$\cos(\frac{\pi}{4}+\frac{2\pi}{3})=a-\frac{\sqrt{2}}{4}$
$\cos(\frac{\pi}{4}+\frac{4\pi}{3})=-a-\frac{\sqrt{2}}{4}$
To find $a$, simply subtract and use the appropriate sum-product relation:
$2a=\cos(\frac{\pi}{4}+\frac{2\pi}{3})-\cos(\frac{\pi}{4}+\frac{4\pi}{3})=2\sin(\frac{(\frac{\pi}{4}+\frac{2\pi}{3})+(\frac{\pi}{4}+\frac{4\pi}{3})}{2})\sin(\frac{(\frac{\pi}{4}+\frac{4\pi}{3})-(\frac{\pi}{4}+\frac{2\pi}{3})}{2})=2\sin(\frac{5\pi}{4})\sin(\frac{\pi}{3})$
Then $\sin(\frac{5\pi}{4})=(-\sqrt{2})/2, \sin(\frac{\pi}{3})=(\sqrt{3})/2$ and we get $a=(-\sqrt{6})/4$.