What is a safe way to root a device ? It looks like rooting a device require using uncertified app, are any of these app open source ? how do we know they are safe to use ?
The best method would be this way:
 unlock bootloader>flash custom recovery from fastboot>flash super SU .zip file from recovery 
if this is possible, on some phones it isn't..
If you by safe way mean "the way that won't screw your device" then there is no way, in every possible way of rooting it's possible that something goes wrong but in most times flashing stock firmware resolve trouble.