Lets back to start, how did u brick ur s4? flash wrong firmware/ custom rom? If yes, its normal bcoz the efs partition is corrupted. As long u flash the right firmware for ur phone it will be fine ( dont try to downgrade 4.3 to 4.2 though it will brick ur phone due to knox bootloader blocking the flash)
Here the things u should do.
1.download andromizer, go to tools, choose imei backup/restore. select backup.(again, need root) save a copy to pc.
2. Download the right firmware, either gti9500 or 9505(lte version).Check ur s4 model.
3.flash using odin, plz make sure re-partion is UNTICK.
4.always do factory reset before and after flashing new firmware.
Normal flashing with the right firmware will not make ur imei lost. hell, i even flash the black edition on my s4.u just need to know what are u doing.
I did that. But still loses my imei. Perhaps the firmware that i downloaded, "JB4.3 Malaysia" is somehow corrupted due to my shitty Streamyx connection. But owelp, seems like theres hella lots of firmware bugs, might as well stuck with my JB4.3