basic fixes for ext/gd
further fixes for ext/gd