Thanks for all the help, I got it to work. The main thing was just that I had to make the image square and set the resolution at line 3 and line 9 to be my image's resolution.
No problem! I'm glad it's working :)
I just uploaded a resize patch for Python mode, but I'm also working on a (hopefully more stable) Java version that'll actually spell out error messages and make debugging easier like it should be. Thanks for hanging in there and helping me make my scripts better!