Update gpio.py

fix setting direction
fix read after write (reset file pointer after write)