By the way: If you do not wish to read the whole story, you may skip to the solution.
StoryLong story short, after trying a lot of things, I simply decided to just flash a stock firmware through Odin and so I went ahead and grabbed the latest 4.4.2 KitKat firmware available (in my case it was for Slovakia) from SamMobile.
After waiting a few minutes for Odin to transfer all of the files, I was near the end (at system.img.ext4) and I said to myself "I'm almos there!" when all of a sudden I see hidden.img.ext4 and below it (FAIL!) (EXT4). At this point, the phone freezed in Download mode and Odin displayed FAIL!. After rebooting the device, I ended up with the screen "Firmware upgrade encountered an error".
I then said "OK, if this firmware does not want to flash, I will just download my previous one (Germany)". The Germany firmware managed to flash succesfully but then the phone would begin to randomly reboot at certain points. Data wipe, cache wipe, system wipe, re-flash, dalvik wipe, Kies, and simply nothing would solve the rebooting issue.
I was then stuck to the point where I said to myself "is this the end?" since going back to an older firmware build of Android 4.4.2 would cause my phone to reboot and not being able to upgrade to the latest one due to an error, I was nearly out of hope but still kept trying to fix this problem using various methods such as booting to recovery mode immediatelly after the firmware is flashed until I finally stumbled upon my solution.
- After flashing the stock firmware through Odin and ending up with the error message, take off the battery and put it back in.
- Begin holding the Volume down + Home + Power keys simultaneously to boot into Download mode.
- Start the Odin program on your computer and connect your phone. It will still recognize it, so don't worry about that.
- Now download the CWM Recovery package for your specific model (check out this post for downloads).
- In the PDA field, select the CWM Recovery .tar.md5 file and click on Start.
- IMMEDIATELY, after the phone's screen turns off and it vibrates, begin holding the Volume up + Home buttons together and you should end up in CWM Recovery
- Now don't do anything but just choose reboot system now.
- It should tell you that some package is missing and that it wants to install it, choose Yes.
- Next, it may ask for root, so once again choose Yes.
- Finally, your phone should reboot and your firmware should be working properly. In case the phone reboots back into CWM Recovery instead, just choose reboot system now again and this time it should boot normally.