Pidfile writing now works in python2 and python3.