Fixed empty pidfile issue with python 3.

Fixed empty pidfile issue with python 3. Also removes empty or broken pidfiles upon starting.