It's always the same- excessive nutrients. What nutrient exactly? As stated earlier, diatoms utilize silicates. Cyanobacteria is a photosynthetic bacteria, that thrives on nutrient rich water and light. Water changes and cutting back on feeding is the best defense, providing you don't have detritus(uneaten food and fish poop) building up somewhere, like a canister filter perhaps. Then that would need to be addressed.