How do you know that it's a glitch in the coding? You can't prove that, unless you have the programming source. But look at the circumstance of the appearance of Aeris's ghost in the game and the appearance of Zack's ghost in the photo, both of them match, proving that the Aeris's ghost is not a glitch, despite the effect of her ghost before she died though, unless that was meant to be a prediction for Cloud. You know what's funny? He doesn't seem surprised when she died, but then again, that could be his personality [trauma casued by his mother death] but who knows.
Well just because you see Zack's ghost doesn't prove it wasn't a glich, it could have been and when making AC they decide to make the glich into something. I don't think Square planned that far ahead to be honest. But thats my opinion though!