A Safe Ethical System for Intelligent Machines