Not sure it wil work for you but what I did:
- reboot into trwp
- wipe > advanched > check all but leave internal storage intact (keep unchecked)
- turn off device (yes, without an OS installed) (do not skip this, no idea why, but I had to do this!)
- turn on and reboot into recovery trwp again
- install /flash the rom
- hopefully no error 7
- then reboot device normally
- leave it alone for some time while it does it thing
tada: miui8 on your phone
(then I added supersu for rooted, as my rom version didnt seem to have internal root.)