Look at the white horizontal lines on the image you posted. They're not evenly spaced out - they get wider towards the bottom of the image. This means that your map image is not made using an Equirectangular projection, and is probably a Mercator projection image.
The code you have posted which converts lat/long to Y/X just by offset and scaling would only work for Equirectangular projection images.
For mercator projections, the conversion is more complex. Please see Covert latitude/longitude point to a pixels (x,y) on mercator projection.
So you have two options:
A) Use equirectangular projection map images
B) Continue using Mercator map images, and fix your lat/long -> Y/X conversion algorithm