Extract the files from the Factory image, until you have the following files together in one folder
bootloader-hammerhead-hhz12d.img
radio-hammerhead-m8974a-2.0.50.2.21.img
cache.img
boot.img
userdata.img
system.img
openrecovery-twrp-2.8.1.0-hammerhead.img

Boot into Bootloader Mode (Power + Volume Down) & run the following commands:

this next step is optional, but if you want a completely clean flash, or you haven’t done a fresh install recently (ie. before 4.4.4) I recommend doing this for 5.0. Note this will wipe your SD card so make a backup!

fastboot flash userdata userdata.img

Once they are all complete, reboot into recovery and perform a factory reset.

If you need Root, reboot back into fastboot mode and run the Chainfire installer downloaded earlier.

Once your done, reboot your phone.
The first boot will take a while so go make a brew, once its booted your done. enjoy 🙂