There are two ways to fix this.
First fix:
Nvidia: Go into the Nvidia Control Panel, open the "Adjust desktop size and position" menu, select "Aspect ratio" scaling and set "Perform scaling on:" to "GPU".

AMD: Open the My Digital Flat-Panels
part from the left of the Catalyst Control Panel, then, enable gpu scaling
and pick maintain aspect ratio
.

Image courtesy amd.com.
Intel: Open Intel HD Graphics Panel, open the display menu, switch to 1024x768 and make sure the "Maintain display scaling" button is ticked (not scale full screen), open game while in this mode.

or if you have the legacy Intel Graphics Media Accelerator, you should open it, select display settings
and click on the Aspect Ratio Options
button. In there, select "Maintain Aspect Ratio" and save.

Image courtesy intel.com.

Image courtesy techtoggle.com.
Second fix: Play in windowed mode.