Edit the /boot/config.txt file and add the following :
hdmi_force_hotplug=1
hdmi_cvt=320 240 60 1 0 0 0
hdmi_group=2
hdmi_mode=87
For reference :
hdmi_force_hotplug=1 Use HDMI mode even if no HDMI monitor is detected
hdmi_cvt=<width> <height> <framerate> <aspect> <margins> <interlace> <rb>
width width in pixels
height height in pixels
framerate framerate in Hz
aspect aspect ratio 1=4:3, 2=14:9, 3=16:9, 4=5:4, 5=16:10, 6=15:9
margins 0=margins disabled, 1=margins enabled
interlace 0=progressive, 1=interlaced
rb 0=normal, 1=reduced blanking
hdmi_group=2 hdmi type DMT
hdmi_mode=87 custom mode