The solution is the factory reset but you will lose all data including photos. But then again if i wipe cache i get the same black screen on boot. So after i have flashed the stock firmware via ODIN http://forum.xda-developers.com/galaxy-s4/general/i9505xxuhoa7-odin-files-100-t3043983 i can wipe cache every time without getting stuck into a black screen, phone boots without error.