As a system image is usually created onto external media, then it cannot be infected by whatever may have infected the computer, but prior to creating one it is best to run a chkdsk /f and a robust antimalware scan so that you aren't saving a corrupt or infected volume.
Being a Win 7 user, I had to Google for that and found -
http://www.thewindowsclub.com/create-restore-system-image-windows-8-1If you are using an OEM machine and you have a Recovery partition, then also check the box for Data D:
However, to restore with it, the article says to tap F8 as you switch on which doesn't work in Win 8.1 but from an elevated cmd prompt you can enter -
bcdedit /set bootmenupolicy legacy
exit
Then reboot.
Tapping F8 as you switch on will now get you into the advanced boot options.
If you wanted to get rid of the F8 provision - although I can't think why, use standard instead of legacy in the bcdedit cmd.
This article goes into more detail with an alternative method of getting to the recovery with a system image, but with the F8 option enabled, should you not otherwise be able to boot up normally, F8 will pull you out of the mire.
https://www.winhelp.us/system-image-backup-in-windows-8-1.html