If you have rooted your Xperia Z3 and looking around for methods to install stock Android 5.1.1 firmware without losing root, the folks at XDA forum have a perfect solution for this. A member named G-FACE has shared a collection latest Android firmwares files, which are already rooted and have XZ dual recovery in it.
All you need for this is a rooted phone but with locked bootloader. How? Click here for help. The pre-rooted firmwares are available for all models of Xperia Z3 such as D6603, D6633 and D6653. The best part is since these firmwares are pre-rooted you have full freedom of choosing and installing the ones of your choice. Also, the firmwares includes both generic and carrier-branded versions. After installation, you don't have take the pain of rooting your device again.
Following is a guide to help you installing the pre-rooted Android 5.1.1 files. But before you proceed, do not forget to check the model number of your phone and then flash files accordingly. Your Xperia Z3 should be rooted with a custom recovery installed. The guide below uses TWRP recovery. Also, do not forget to create a backup of all data of the phone.
How to install pre-rooted Android 5.1.1 stock firmware on Xperi Z3
Step-1: Download pre-rooted Android 5.1.1 firmware for Xperia Z3
Step-2: Copy the downloaded file to the phone's storage and remember the location
Step-3: Boot the Z3 into recovery mode. If you have rooted your phone, use Quick Boot app from the Play store to boot into recovery mode. Alternatively, press and hold Volume Down and Power buttons together
Step-4: In recovery mode, perform a nandroid backup
Step-5: Then perform wiping task, for that in TWRP recovery select Wipe then Advanced wipe. On the next screen select options such as Dalvik cache, System, Data and Cache. Then do a swipe on the swipe to wipe option
Step-6: When the process is completed, return to the main recovery menu and select Install then head over to the folder where you have saved the pre-rooted stock firmware. Select it and do a swipe to install option below
Step-7: After the installation finishes, reboot the phone
When your phone boots up successfully and loads all the files, you should be running on a pre-rooted firmware. To know more about the pre-rooted firmware, head over to the development thread over XDA.